package cn.hx.malluser.service.impl;

import cn.hx.malluser.utils.MD5Util;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hx.malluser.entity.UmsMember;
import cn.hx.malluser.service.UmsMemberService;
import cn.hx.malluser.mapper.UmsMemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *
 */
@Service
public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember> implements UmsMemberService {

    @Resource
    private UmsMemberMapper umsMemberMapper;

    @Override
    public UmsMember queryByPhoneAndPwd(String phone, String password) {
        if (phone != null && password != null) {
            QueryWrapper<UmsMember> wrapper = new QueryWrapper<>();
            wrapper.eq("phone", phone);
            UmsMember umsMember = umsMemberMapper.selectOne(wrapper);
            if (umsMember != null) {
                if (MD5Util.encrypt(password).equals(umsMember.getPassword())) {
                    return umsMember;
                }
            }
        }
        return null;
    }
}




